import request from '../util/request'
import axios from "axios";

const baseUrl = process.env.NODE_ENV === 'production' ? '' : '/vehicleMap'

export function addApi(form) {
  return request({
    url:baseUrl+ "/lccharger",
    method: "post",
    data: form
  });
}

export function delApi(multipleSelection) {
  let ids = new Array();
  for (let i = 0; i < multipleSelection.length; i++) {
    ids[i] = multipleSelection[i].id
  }
  return request({
    url:baseUrl+ '/lccharger',
    method: 'delete',
    data: ids
  });
}

export function batchUpdatePriceApi(editdata) {

  const data = editdata
  return request({
    url:baseUrl+ '/lccharger',
    method: 'put',
    data: data
  })
}

export function bindLockApi(lockId, chargerId) {
  let bindData = {
    id: lockId,
    battery: chargerId
  };
  return request({
    url:baseUrl+ '/lclock',
    method: 'put',
    data: bindData
  });
}

export function restartApi(chargerId) {
  let data = {
    id: chargerId
  };
  return request({
    url:baseUrl+ '/lccharger/restart',
    method: 'get',
    params: data
  });
}

export function getRateApi(id) {
  return request({
    url:baseUrl+ '/lccharger/getRate?id='+id,
    method: 'get',
  });
}

export function loadChargersApi(params) {
 
   return request({
    url:baseUrl+ "/lccharger",
    methods: "get",
    params: params
  });

}

export function loadChargersListApi(params) {
 
  return request({
   url:baseUrl+ "/lccharger/list",
   methods: "get",
   params: params
 });

}

export function submitExportApi(form) {
  
   return axios.get(baseUrl + "/lccharger/export", {
    params: {
      managerId:form.managerId,
      parkfieldId: form.parkfieldId,
      startTime: form.startTime,
      endTime: form.endTime
    },
    responseType: "blob"
  });

}
